#ifdef USE_WHITEBOX_INJECTION
/*
 * Intended to give stubs used in xact whitebox injection tests there index and names.
 * Be aware that when adding new stubs, please add it to the end to to avoid
 * renumbering the existing stubs; if you remove a stub, consider leaving a gap
 * in the numbering sequence for the benefit of upgrading.
 *
 */
#define MAX_WHITEBOX_STUB_NUM	45

/* Stub indexs */

#define REMOTE_PREPARE_SEND_ALL_FAILED_INDEX		1
#define REMOTE_PREPARE_SEND_LAST_DN_FAILED_INDEX	2
#define REMOTE_PREPARE_SEND_LAST_CN_FAILED_INDEX	3
#define REMOTE_PREPARE_MESSAGE_REPEAT_CN_INDEX		4
#define REMOTE_PREPARE_MESSAGE_REPEAT_DN_INDEX		5
#define REMOTE_PREPARE_FAILED_AFTER_SEND_INDEX		6
#define REMOTE_COMMIT_SEND_ALL_FAILED_INDEX			7
#define REMOTE_COMMIT_SEND_LAST_CN_FAILED_INDEX		8
#define REMOTE_COMMIT_SEND_LAST_DN_FAILED_INDEX		9
#define REMOTE_COMMIT_MESSAGE_REPEAT_CN_INDEX		10
#define REMOTE_COMMIT_MESSAGE_REPEAT_DN_INDEX		11
#define REMOTE_COMMIT_FAILED_AFTER_SEND_INDEX		12
#define REMOTE_ABORT_SEND_ALL_FAILED_INDEX			13
#define REMOTE_ABORT_SEND_LAST_CN_FAILED_INDEX		14
#define REMOTE_ABORT_SEND_LAST_DN_FAILED_INDEX		15
#define REMOTE_ABORT_MESSAGE_REPEAT_CN_INDEX		16
#define REMOTE_ABORT_MESSAGE_REPEAT_DN_INDEX		17
#define REMOTE_ABORT_FAILED_AFTER_SEND_INDEX		18
#define SAVEPOINT_DEFINE_FAILED_INDEX				19
#define SAVEPOINT_RELEASE_FAILED_INDEX				20
#define SAVEPOINT_ROLLBACK_FAILED_INDEX				21
#define SYNC_REPLICATE_CYCLE_INDEX					22
#define XLOG_FLUSH_INDEX							23
#define WAL_SENDER_MAINLOOP_INDEX					24
#define WAL_RECEIVER_PROCESS_DATA_INDEX				25
#define LOCAL_COMMIT_PREPARED_FAILED_INDEX			26
#define LOCAL_ABORT_PREPARED_FAILED_INDEX			27
#define GET_GTS_FAILED_INDEX						28
#define LOCAL_PREPARED_FAILED_A_INDEX				29
#define LOCAL_PREPARED_FAILED_B_INDEX				30
#define LOCAL_PREPARED_CLOG_FAILED_INDEX			31
#define LOCAL_PREPARED_TWOPHASEFILE_FAILED_INDEX	32
#define LOCAL_PREPARE_TRANSACTION_BLOCK_INDEX		33
#define PUSH_TRANSACTION_BEFORE_PUSH_FAILED_INDEX	34
#define PUSH_TRANSACTION_AFTER_PUSH_FAILED_INDEX		35
#define LOCAL_COMMIT_SUBTRANSACTION_FAILED_INDEX		36
#define LOCAL_ABORT_SUBTRANSACTION_FAILED_INDEX			37
#define SYNC_REL_RECEIVE_CANCELED_INDEX					38
#define AFTER_REMOTE_COMMIT_FAILED_INDEX				39
#define AFTER_ALL_COMMIT_FAILED_INDEX					40
#define LOCAL_PREPARED_XLOG_INDEX						41
#define PRIMARY_CHECKPOINT_KEEP_XLOG_INDEX				42
#define STANDBY_XLOGREDO_KEEP_XLOG_INDEX				43

/* pgxc_node_remote_prepare */
#define REMOTE_PREPARE_SEND_ALL_FAILED			(&MainInjectionStubArray[REMOTE_PREPARE_SEND_ALL_FAILED_INDEX])
#define REMOTE_PREPARE_SEND_LAST_DN_FAILED		(&MainInjectionStubArray[REMOTE_PREPARE_SEND_LAST_DN_FAILED_INDEX])
#define REMOTE_PREPARE_SEND_LAST_CN_FAILED		(&MainInjectionStubArray[REMOTE_PREPARE_SEND_LAST_CN_FAILED_INDEX])
#define REMOTE_PREPARE_MESSAGE_REPEAT_CN		(&MainInjectionStubArray[REMOTE_PREPARE_MESSAGE_REPEAT_CN_INDEX])
#define REMOTE_PREPARE_MESSAGE_REPEAT_DN		(&MainInjectionStubArray[REMOTE_PREPARE_MESSAGE_REPEAT_DN_INDEX])
#define REMOTE_PREPARE_FAILED_AFTER_SEND		(&MainInjectionStubArray[REMOTE_PREPARE_FAILED_AFTER_SEND_INDEX])

/* pgxc_node_remote_commit */
#define REMOTE_COMMIT_SEND_ALL_FAILED			(&MainInjectionStubArray[REMOTE_COMMIT_SEND_ALL_FAILED_INDEX])
#define REMOTE_COMMIT_SEND_LAST_CN_FAILED		(&MainInjectionStubArray[REMOTE_COMMIT_SEND_LAST_CN_FAILED_INDEX])
#define REMOTE_COMMIT_SEND_LAST_DN_FAILED		(&MainInjectionStubArray[REMOTE_COMMIT_SEND_LAST_DN_FAILED_INDEX])
#define REMOTE_COMMIT_MESSAGE_REPEAT_CN			(&MainInjectionStubArray[REMOTE_COMMIT_MESSAGE_REPEAT_CN_INDEX])
#define REMOTE_COMMIT_MESSAGE_REPEAT_DN			(&MainInjectionStubArray[REMOTE_COMMIT_MESSAGE_REPEAT_DN_INDEX])
#define REMOTE_COMMIT_FAILED_AFTER_SEND			(&MainInjectionStubArray[REMOTE_COMMIT_FAILED_AFTER_SEND_INDEX])

/*
 * Temporarily remove the white box at the rollback location because the code's original logic does not
 * throw an error here. If an error is thrown, it will result in continuous errors at the rollback
 * location, eventually triggering a panic.
 */
/* pgxc_node_remote_abort */
#define REMOTE_ABORT_SEND_ALL_FAILED			(&MainInjectionStubArray[REMOTE_ABORT_SEND_ALL_FAILED_INDEX])
#define REMOTE_ABORT_SEND_LAST_CN_FAILED		(&MainInjectionStubArray[REMOTE_ABORT_SEND_LAST_CN_FAILED_INDEX])
#define REMOTE_ABORT_SEND_LAST_DN_FAILED		(&MainInjectionStubArray[REMOTE_ABORT_SEND_LAST_DN_FAILED_INDEX])
#define REMOTE_ABORT_MESSAGE_REPEAT_CN			(&MainInjectionStubArray[REMOTE_ABORT_MESSAGE_REPEAT_CN_INDEX])
#define REMOTE_ABORT_MESSAGE_REPEAT_DN			(&MainInjectionStubArray[REMOTE_ABORT_MESSAGE_REPEAT_DN_INDEX])
#define REMOTE_ABORT_FAILED_AFTER_SEND			(&MainInjectionStubArray[REMOTE_ABORT_FAILED_AFTER_SEND_INDEX])

/*AbortSubTransaction */
#define LOCAL_ABORT_SUBTRANSACTION_FAILED		(&MainInjectionStubArray[LOCAL_ABORT_SUBTRANSACTION_FAILED_INDEX])

/* savepoint */
#define SAVEPOINT_DEFINE_FAILED					(&MainInjectionStubArray[SAVEPOINT_DEFINE_FAILED_INDEX])
#define SAVEPOINT_RELEASE_FAILED				(&MainInjectionStubArray[SAVEPOINT_RELEASE_FAILED_INDEX])
#define SAVEPOINT_ROLLBACK_FAILED				(&MainInjectionStubArray[SAVEPOINT_ROLLBACK_FAILED_INDEX])

/* wal log, only test sleep */
#define SYNC_REPLICATE_CYCLE						(&MainInjectionStubArray[SYNC_REPLICATE_CYCLE_INDEX])
#define XLOG_FLUSH									(&MainInjectionStubArray[XLOG_FLUSH_INDEX])
#define WAL_SENDER_MAINLOOP							(&MainInjectionStubArray[WAL_SENDER_MAINLOOP_INDEX])
#define WAL_RECEIVER_PROCESS_DATA					(&MainInjectionStubArray[WAL_RECEIVER_PROCESS_DATA_INDEX])

/* FinishPreparedTransaction */
#define LOCAL_COMMIT_PREPARED_FAILED				(&MainInjectionStubArray[LOCAL_COMMIT_PREPARED_FAILED_INDEX])
#define LOCAL_ABORT_PREPARED_FAILED					(&MainInjectionStubArray[LOCAL_ABORT_PREPARED_FAILED_INDEX])

/* GetGlobalTimestampGTMDirectly */
#define GET_GTS_FAILED								(&MainInjectionStubArray[GET_GTS_FAILED_INDEX])

/* PrepareTransaction, EndPrepare */
#define LOCAL_PREPARED_FAILED_A						(&MainInjectionStubArray[LOCAL_PREPARED_FAILED_A_INDEX])
#define LOCAL_PREPARED_FAILED_B						(&MainInjectionStubArray[LOCAL_PREPARED_FAILED_B_INDEX])
#define LOCAL_PREPARED_CLOG_FAILED					(&MainInjectionStubArray[LOCAL_PREPARED_CLOG_FAILED_INDEX])
#define LOCAL_PREPARED_TWOPHASEFILE_FAILED			(&MainInjectionStubArray[LOCAL_PREPARED_TWOPHASEFILE_FAILED_INDEX])
#define LOCAL_PREPARED_XLOG							(&MainInjectionStubArray[LOCAL_PREPARED_XLOG_INDEX])

/* PrepareTransactionBlock */
#define LOCAL_PREPARE_TRANSACTION_BLOCK				(&MainInjectionStubArray[LOCAL_PREPARE_TRANSACTION_BLOCK_INDEX])

/* PushTransaction */
#define PUSH_TRANSACTION_BEFORE_PUSH_FAILED		(&MainInjectionStubArray[PUSH_TRANSACTION_BEFORE_PUSH_FAILED_INDEX])
#define PUSH_TRANSACTION_AFTER_PUSH_FAILED		(&MainInjectionStubArray[PUSH_TRANSACTION_AFTER_PUSH_FAILED_INDEX])

/* CommitSubTransaction */
#define LOCAL_COMMIT_SUBTRANSACTION_FAILED			(&MainInjectionStubArray[LOCAL_COMMIT_SUBTRANSACTION_FAILED_INDEX])

/* SyncRepWaitForLSN */
#define SYNC_REL_RECEIVE_CANCELED					(&MainInjectionStubArray[SYNC_REL_RECEIVE_CANCELED_INDEX])

/* CommitTransaction */
#define AFTER_REMOTE_COMMIT_FAILED					(&MainInjectionStubArray[AFTER_REMOTE_COMMIT_FAILED_INDEX])
#define AFTER_ALL_COMMIT_FAILED						(&MainInjectionStubArray[AFTER_ALL_COMMIT_FAILED_INDEX])

/* keep xlog */
#define PRIMARY_CHECKPOINT_KEEP_XLOG				(&MainInjectionStubArray[PRIMARY_CHECKPOINT_KEEP_XLOG_INDEX])
#define STANDBY_XLOGREDO_KEEP_XLOG					(&MainInjectionStubArray[STANDBY_XLOGREDO_KEEP_XLOG_INDEX])
#endif
